﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using com.dz.ht.common;

namespace com.dz.ht.components
{
    public class ObjectManger
    {
        #region 不同程序集反射

        private static object CreateObject(string path, string TypeName)
        {
            object obj = null;
            try
            {
                obj = Assembly.Load(path).CreateInstance(TypeName);

            }
            catch (System.Exception ex)
            {
                LogHelper.Error("反射获取对象失败" + ex.ToString());
            }

            return obj;
        }
        /// <summary>
        /// 创建数据库信息类接口
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static IBookObject CreateDbObj(string dbTypename)
        {
            //从程序集创建对象实例

            string TypeName = "com.dz.ht.components.book." + dbTypename + ".CollectBookManager";
            object objType = CreateObject("HT-2", TypeName);
            return (IBookObject)objType;
        }



        #endregion
    }
}
